Repository navigation
feat(ContextMenu): createContextMenu and useContextMenu, a headless context menu (spec:AST-107 FR8) - #8693
feat(ContextMenu): createContextMenu and useContextMenu, a headless context menu (spec:AST-107 FR8)#8693vjeux wants to merge 12 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This pull request is on hold for a spec decision. createContextMenu and useContextMenu rely on spec:AST-107 FR8, which is still only in the open #8600; this head also adds requirements that main does not state yet (architecture:layer-runtime INV13, three springs.contextMenu* roles in spec:AST-094 FR4, the spec:AST-057 reword and component:ContextMenu DEC-2), and the stacked context request cites an AST-094 FR43 that no record contains. An engineering owner needs to provide the governing spec for the headless menu (landing #8600 with the FR43 text would do it) and to approve or reject these record changes by commenting /approve-spec 154a743b3fa668001077d82c8b3c9dcb37d70027 on this pull request; as an engineering owner, the author may do so too. Independently of that decision, please address the following:
- Land the stacked predecessors and rebase, so that this diff is only the headless menu; it currently carries about 44,900 authored lines.
useContextMenureads its ref once, so a row that mounts later or swaps its element gets no menu.- The hook's cleanup unmounts the menu's React root during React's commit, which React reports as a race in all six hook tests.
- Under a held finger, the headless menu opens without the trigger lift that
spec:AST-094FR33 requires. useContextMenudocuments apresentationoption that its type does not accept.
[Automated review]
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| ContextMenu · Storybook | 111.4 kB (+328 B) · 19.9 kB CSS (0) | 1,586 (+832) | ✗ · ✓ · ✓ |
| lab/MediaPlayer | 🔴 111.4 kB (+80.0 kB) · 165 B CSS (0) | — | — · — · — |
| lab/ChatVirtualizer | 🔴 113.3 kB (+55.1 kB) · 223 B CSS (0) | — | — · — · — |
42 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/ThreeDChart | 🔴 47.7 kB (+42.5 kB) · 20 B CSS (0) | — | — · — · — |
| lab/MediaPlayerElement | 🔴 47.6 kB (+40.6 kB) · 177 B CSS (0) | — | — · — · — |
| lab/ChatTypingIndicator | 🔴 66.6 kB (+40.0 kB) · 612 B CSS (0) | — | — · — · — |
| lab/TabBar | 🔴 124.5 kB (+39.6 kB) · 1.8 kB CSS (0) | — | — · — · — |
| lab/LineClamp | 🔴 52.9 kB (+38.1 kB) · 168 B CSS (0) | — | — · — · — |
| lab/NavigationScreen | 🔴 121.6 kB (+34.6 kB) · 1.5 kB CSS (0) | — | — · — · — |
| lab/NavigationStack | 🔴 121.6 kB (+34.6 kB) · 1.5 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 🔴 92.4 kB (+28.7 kB) · 1.2 kB CSS (0) | — | — · — · — |
| lab/ListInput | 🔴 129.7 kB (+28.0 kB) · 1.3 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 🔴 339.1 kB (+24.8 kB) · 2.7 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 🔴 315.2 kB (+24.2 kB) · 2.4 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 🔴 123.3 kB (+23.6 kB) · 2.3 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 🔴 148.0 kB (+23.6 kB) · 751 B CSS (0) | — | — · — · — |
| lab/TransferList | 🔴 163.7 kB (+19.6 kB) · 1.4 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 🔴 175.1 kB (+18.3 kB) · 1.6 kB CSS (0) | — | — · — · — |
| lab/Tour | 🔴 126.7 kB (+14.6 kB) · 1.0 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 🔴 145.7 kB (+10.7 kB) · 1.1 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 🔴 144.0 kB (+10.5 kB) · 773 B CSS (0) | — | — · — · — |
| DateInput | 🔴 222.3 kB (+8.2 kB) · 19.4 kB CSS (+250 B) | — | — · — · — |
| DateTimeInput | 🔴 245.8 kB (+7.9 kB) · 21.1 kB CSS (+231 B) | — | — · — · — |
| lab/TabBarItem | 🔴 11.6 kB (+7.7 kB) · 1.8 kB CSS (0) | — | — · — · — |
| lab/VideoPlayer | 239.5 kB (+425 B) · 2.1 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 112.4 kB (+354 B) · 20.3 kB CSS (0) | — | — · — · — |
| Table | 127.3 kB (+353 B) · 21.5 kB CSS (0) | — | — · — · — |
| TableCell | 112.5 kB (+350 B) · 20.5 kB CSS (0) | — | — · — · — |
| lab/AudioPlayer | 241.4 kB (+339 B) · 1.8 kB CSS (0) | — | — · — · — |
| Markdown | 211.8 kB (+336 B) · 23.8 kB CSS (0) | — | — · — · — |
| lab/Comments | 392.3 kB (+202 B) · 2.5 kB CSS (0) | — | — · — · — |
| PowerSearch | 326.4 kB (+146 B) · 27.7 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 385.2 kB (+8 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 192.2 kB (+4 B) · 1.9 kB CSS (0) | — | — · — · — |
| charts/Chart | 268.7 kB (0) · 516 B CSS (0) | — | — · — · — |
| List | 20.5 kB (0) · 3.0 kB CSS (0) | — | ✓ · ✓ · — |
| ListItem | 84.5 kB (0) · 13.0 kB CSS (0) | — | ✓ · ✓ · ✓ |
| lab/MediaCaptionsButton | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaFullscreenButton | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaPlaybackRate | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaPlayButton | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaSeekButton | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaTime | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaTimeSlider | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaVolume | 230.7 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
Visual changes: 1 snapshot in 1 component
A change is a question for the reviewer, not a failure.
| Component · story | Before | After | Diff |
|---|---|---|---|
| ContextMenu · Default (neutral, dark) · same image also changed on another pull request, not proven from main | ![]() |
![]() |
![]() |
Inheritance checked against the 8 newest reports of other pull requests.
Package size: @astryxdesign/core 8.16 MB packed (+25.5 kB); no new dependencies.
API changes: core +19 · ~0 · −0
19 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Hooks · hook useContextMenu |
hook useContextMenu: (ref: RefObject<HTMLElement | null>, options: UseContextMenuOptions) => UseContextMenuResult |
import {useContextMenu} from '@astryxdesign/core'; useContextMenu(…) |
| + | core |
. · Functions · function createContextMenu |
function createContextMenu: (element: HTMLElement, initialOptions: CreateContextMenuOptions) => ContextMenuController |
import {createContextMenu} from '@astryxdesign/core'; createContextMenu(…) |
| + | core |
. · Types · type ContextMenuContentRenderer |
type ContextMenuContentRenderer = (container: HTMLElement) => (() => void) | undefined |
import type {ContextMenuContentRenderer} from '@astryxdesign/core' |
| + | core |
. · Types · interface ContextMenuController |
interface ContextMenuController |
import type {ContextMenuController} from '@astryxdesign/core' |
| + | core |
. · Types · interface ContextMenuPoint |
interface ContextMenuPoint |
import type {ContextMenuPoint} from '@astryxdesign/core' |
| + | core |
. · Types · type CreateContextMenuOptions |
type CreateContextMenuOptions = ContextMenuSharedOptions & ({ items: ReadonlyArray<ContextMenuOption>; render?: undefined } | { items?: undefined; render: ContextMenuContentRenderer }) |
import type {CreateContextMenuOptions} from '@astryxdesign/core' |
| + | core |
. · Types · type UseContextMenuOptions |
type UseContextMenuOptions = UseContextMenuSharedOptions & ({ items: ReadonlyArray<ContextMenuOption>; menuContent?: undefined } | { items?: undefined; menuContent: ReactNode }) |
import type {UseContextMenuOptions} from '@astryxdesign/core' |
| + | core |
. · Types · interface UseContextMenuResult |
interface UseContextMenuResult |
import type {UseContextMenuResult} from '@astryxdesign/core' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · ContextMenuContentRenderer |
ContextMenuContentRenderer (.) |
import {ContextMenuContentRenderer} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · ContextMenuController |
ContextMenuController (.) |
import {ContextMenuController} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · ContextMenuPoint |
ContextMenuPoint (.) |
import {ContextMenuPoint} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · CreateContextMenuOptions |
CreateContextMenuOptions (.) |
import {CreateContextMenuOptions} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · UseContextMenuOptions |
UseContextMenuOptions (.) |
import {UseContextMenuOptions} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · UseContextMenuResult |
UseContextMenuResult (.) |
import {UseContextMenuResult} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · createContextMenu |
createContextMenu (.) |
import {createContextMenu} from '@astryxdesign/core/ContextMenu' |
| + | core |
./ContextMenu · Also exported from an earlier entry point · useContextMenu |
useContextMenu (.) |
import {useContextMenu} from '@astryxdesign/core/ContextMenu' |
| + | core |
./hooks · Also exported from an earlier entry point · UseContextMenuOptions |
UseContextMenuOptions (.) |
import {UseContextMenuOptions} from '@astryxdesign/core/hooks' |
| + | core |
./hooks · Also exported from an earlier entry point · UseContextMenuResult |
UseContextMenuResult (.) |
import {UseContextMenuResult} from '@astryxdesign/core/hooks' |
| + | core |
./hooks · Also exported from an earlier entry point · useContextMenu |
useContextMenu (.) |
import {useContextMenu} from '@astryxdesign/core/hooks' |
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
This pull request is on hold for an engineering owner's spec decision. createContextMenu and useContextMenu cite spec:AST-107 FR8, which is still only in the open #8600; under a held finger the headless menu opens without the trigger lift that spec:AST-094 FR33 requires; and this head adds requirements that main does not state yet (architecture:layer-runtime INV13, three springs.contextMenu* roles in spec:AST-094 FR4, the spec:AST-057 reword and component:ContextMenu DEC-2). An engineering owner can provide the governing spec by landing #8600, and records the decision on the lift gap and these record changes by commenting /approve-spec 3ccf1bd734180a5740a55d233f0f83978bd29638 on this pull request; as an engineering owner, the author may do so too. Independently of that decision, please address the following:
- Land the stacked predecessors and rebase, so that this diff is only the headless menu; it currently carries about 45,700 authored lines.
useContextMenureads its ref once, so a row that mounts later or is replaced by another node gets no menu.- The hook's cleanup unmounts the menu's React root during React's commit.
- Opens run in a layout effect rather than in the request handler, and that effect names no external system.
useContextMenudocuments apresentationoption that its type does not accept.
[Automated review]
There was a problem hiding this comment.
This pull request is on hold for an engineering owner's spec decision. spec:AST-107 FR8 now governs createContextMenu and useContextMenu, but three things still need an owner: the hook's internal updateContextMenu and bridgeContextMenu paths, which FR6 and FR8 do not admit (the description's own question about a public update(options)); the headless menu opening under a held finger without the trigger lift spec:AST-094 FR33 requires; and record changes main does not state yet (architecture:layer-runtime INV13, three springs.contextMenu* rows in spec:AST-094 FR4, the spec:AST-057 reword and component:ContextMenu DEC-2). An engineering owner records that decision by commenting /approve-spec 7780ee91a17092061ec89a96f47020af939cd92b on this pull request, or amends the records first; as an engineering owner, the author may do so too. Independently of that decision, please address the following:
- Land the stacked predecessors and rebase, so that this diff is only the headless menu; it currently carries about 46,100 authored lines.
useContextMenureads its ref once, so a row that mounts later or is replaced by another node gets no menu.- The hook's cleanup unmounts React roots during React's commit, which React reports in each of the hook's nine tests.
- FR8 says ContextMenu is built on
createContextMenu, but ContextMenu still renders the shared internal view directly. useContextMenuis not exported from@astryxdesign/core/hooks, where AST-107's public contract imports it.- Opens run in a layout effect that fires
onOpenChange, and the new effects do not name what they synchronize. - Closing returns focus to whatever had it before the open, not to the element as FR8 states.
[Automated review]
…its menu in the element's dialog, popover or shadow root; its rows at the menu's layer depth; main dcdb356) into ContextMenu on the factory createContextMenu.tsx: meta#8693's container placement, rows context and wrapper access, with this branch's request core (attachContextMenuRequests) in place of the factory's own context request.
There was a problem hiding this comment.
Incremental review of 7780ee9..64b21e0; prior findings carried: spec_authority, authored_loc, context, user_impact, api, mechanism, evidence_by_spec_claim, concrete_defects, disposition
This pull request is still on hold for an engineering owner's spec decision: the hook's internal updateContextMenu, bridgeContextMenu and rows-context paths, which spec:AST-107 FR6 and FR8 do not admit (the description's own question about a public update(options)); the headless menu opening under a held finger without the trigger lift spec:AST-094 FR33 requires; and record changes main does not state yet (architecture:layer-runtime INV13, three springs.contextMenu* rows in spec:AST-094 FR4, the spec:AST-057 reword and component:ContextMenu DEC-2). An engineering owner records that decision by commenting /approve-spec 64b21e03bd8939f7b45120ad5cae02b5b32340e4 on this pull request, or amends the records first; as an engineering owner, the author may do so too. This push makes the menu usable inside a modal dialog, an open popover and a shadow root, but independently of the hold, please address the following:
- Inside an open Drawer, or any dialog or popover with a transform, the menu now opens away from the pointer (off-screen in a Drawer), because its
position: fixedcursor anchor is laid out against that container. - Land the stacked predecessors and rebase, so that this diff is only the headless menu (about 46,300 authored lines today, and about 2,130 for the menu alone).
useContextMenureads its ref once, so a row that mounts later or is replaced gets no menu, and its cleanup unmounts React roots during React's commit.- FR8 says ContextMenu is built on
createContextMenuand that focus returns to the element on close (inside a shadow root it now falls to the body), anduseContextMenuis still missing from@astryxdesign/core/hooks.
[Automated review]
…pec; the factory closes on a press outside, mouse or finger) into ContextMenu on the factory createContextMenu.test.tsx: both sides add cases at its end; this keeps both, and the finger's outside-press cases take the file's shared clock epoch, since the touch-model cases before them have moved the gesture host's clock past a fresh 100 s.
There was a problem hiding this comment.
Full review of 6f8ba32; the incremental delta could not be read: the merge of main resolves a conflict inside the verification map of packages/core/src/ContextMenu/ContextMenu.spec.md, a spec record, and CodeBunny's earlier review could not be loaded.
This pull request is on hold for an engineering owner's spec decision: spec:AST-107 FR8 governs createContextMenu and useContextMenu, but an owner must approve or reject the hook's internal updateContextMenu, bridgeContextMenu and rows-context paths (FR6 says the hook has no behavior of its own), the headless menu opening under a held finger without the lift spec:AST-094 FR33 requires, and the record changes main does not state yet (architecture:layer-runtime INV13, three springs.contextMenu* rows in AST-094 FR4, the spec:AST-057 reword and DEC-2 in component:ContextMenu). An engineering owner records that decision by commenting /approve-spec 6f8ba32b8d4d4702ca9f64293d0c1b6d0909ffa2 on this pull request, or amends the records first; as an engineering owner, the author may do so too. Independently of the hold, please address the following:
- Land the stacked predecessors and rebase, so this diff is the headless menu alone (about 46,400 authored lines today).
- Inside an open Drawer, or any transformed dialog or popover, the menu opens away from the pointer, off-screen in a Drawer.
- FR8 says ContextMenu is built on
createContextMenuand that focus returns to the element on close, anduseContextMenuis still missing from@astryxdesign/core/hooks. useContextMenureads its ref once and unmounts React roots during React's commit, andscripts/touch-support-bundle.test.mjsandpressableCoverage.test.tsfail on this head.
[Automated review]
…ng its roots without unmounting them inside React's commit; the factory's anchor through a transformed dialog) into ContextMenu on the factory createContextMenu.tsx: the wrapper access carries both this branch's view setter and meta#8693's destroy for React callers; teardown destroys this branch's request core. useContextMenu.tsx: the rows slot's host goes at once and its root renders nothing.
Main rewrote List's readiness cell to state gaps instead of build status. The resolution keeps main's cell and states this branch's row menu facts in that form: what opens a row menu, and its FR13 gap.
The FR10 gap and its current-state line said that the factory and the hook ship and that ContextMenu still takes its own invocation. They now state what the system does: the three share one menu, and ContextMenu takes its invocation on its own wrapper element.
5e9e161 to
64721fa
Compare
|
/approve-spec 64721fa |
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on two points that this head's /approve-spec does not cover: whether createContextMenu may ship while ContextMenu keeps its own invocation instead of being built on it, which spec:AST-107 FR8 and architecture:public-component-api INV21 still require, and whether both APIs may ship without the live template example that architecture:knowledge-contracts INV28 and spec:AST-107 FR5 ask for. An engineering owner, the author included, can settle both by replying on this pull request or by amending those records on main.
Whatever the decision, these need changes:
- Newly live check:
fixedOffsetOfClientPoint(ContextMenu.tsx:279-294) interleavesleft/topwrites withgetBoundingClientRectreads, so every open lays the page out at least twice againstarchitecture:react-component-runtimeINV18; read the 1 px anchor once at its current offset and write once. - Newly live check:
useContextMenu.tsx:153writes the latest-value reflatestRefinside a layout effect, while INV3 routes such a ref only throughuseCommittedRef. - Miss:
createContextMenu.tsx:317keeps{element, handleRef}in React state, which INV1 forbids for DOM nodes; build the attachment once in the factory and pass it down. - The dense docs at
createContextMenu.doc.mjs:138sayrenderfills the menu when it opens, but it runs once at attach and its cleanup runs atdestroy. - Miss: no test fails when a listener (the element's
keydown, the long-press recognizer, or the open menu's documentmousedown) survivesdestroy, whichspec:AST-107FR8's verification asks for.
Claims and files checked
Review mode: full; reason: history
Claims:
- Changeset: attaches ContextMenu's menu to any element without wrapping it - verified (the factory's host is never a child of the element)
- Changeset: a ListItem row keeps
ul > liand its dividers - verified by code (host appended outside the list; ListItem's:last-childdivider rule); tests not run here - Changeset: opens on a long press, a right click, Shift+F10 or the context-menu key - verified by code (the shared context-request module)
- Changeset:
destroyremoves every listener and node it added - verified by enumerating the element listeners, the recognizer, the host and the root's effects; no test counts listeners (finding above) - Title: a headless context menu per AST-107 FR8 - partly: FR8's clause that ContextMenu is built on the factory does not hold yet (owner question)
- Description: a ContextMenu around a ListItem gives
ul > div > liand drops the dividers - verified (the control test and ListItem's divider rule) - Description: both APIs come from the ContextMenu entry, the hook also from the hooks entry - verified (both entry files)
- Description: the menu lives at the end of the element's dialog, popover, shadow root or body, and the element's markup is untouched - verified by code
- Description: ContextMenu's API and output do not change - verified by reading the changed files and the modules that import ContextMenu
- Description: only ContextMenu.tsx and createContextMenu.tsx use the shared root - verified by a repository search for both names
- Description: the lift under a finger and the More actions button stay open - verified (recorded as gaps, approved at this head)
- Description: test runs and counts, preflight results, red-first runs, merge state, one-off controls and rubric results - reported (CI has not run at this head)
- Description: public text carries no internal context - verified (residue scan over the added lines, commits, title, body and branch: no match)
Files:
- .changeset/createcontextmenu-element-options-attaches-conte-k1sw.md - clear
- apps/storybook/stories/ContextMenu.stories.tsx - clear
- docs/specs/components/ContextMenu/ContextMenu.spec.md - clear (approved at this head)
- docs/specs/components/List/List.spec.md - clear (approved at this head)
- packages/cli/foundation/doc-compiler/inputs.test.mjs - clear
- packages/core/src/ContextMenu/ContextMenu.doc.mjs - clear
- packages/core/src/ContextMenu/ContextMenu.tsx - forced layout on open; bypass of the factory held for an owner
- packages/core/src/ContextMenu/tests/createContextMenu.interaction.browser.spec.ts - clear
- packages/core/src/ContextMenu/contextMenuRequests.ts - clear
- packages/core/src/ContextMenu/contextMenuRows.tsx - clear
- packages/core/src/ContextMenu/createContextMenu.doc.mjs - dense
renderdescription - packages/core/src/ContextMenu/createContextMenu.ssr.test.tsx - clear
- packages/core/src/ContextMenu/createContextMenu.test.tsx - no listener check after
destroy - packages/core/src/ContextMenu/createContextMenu.tsx - DOM node in state; long header (non-blocking)
- packages/core/src/ContextMenu/index.ts - clear
- packages/core/src/ContextMenu/useContextMenu.doc.mjs - clear
- packages/core/src/ContextMenu/useContextMenu.test.tsx - clear
- packages/core/src/ContextMenu/useContextMenu.tsx - latest-value ref in a layout effect; long header (non-blocking)
- packages/core/src/List/tests/ListItemContextMenu.test.tsx - clear
- packages/core/src/hooks/index.ts - clear
- scripts/touch-support-bundle.test.mjs - clear
The docsite build checks the ShadCN routes it generates against a reviewed lock. This branch adds two public hooks, so the build stopped at that check. The lock now lists their two routes, hooks/create-context-menu and hooks/use-context-menu. No other route is added, removed or changed.
|
/approve-spec 266812b |
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on two points that this pull request's approved record edits do not settle: whether createContextMenu may ship while ContextMenu keeps its own invocation instead of being built on it, which spec:AST-107 FR8 and architecture:public-component-api INV21 still require, and whether both APIs may ship without the live template example that architecture:knowledge-contracts INV28 and spec:AST-107 FR5 ask for. An engineering owner, the author included, can settle both by replying on this pull request or by amending those records on main.
The new commit's route lock entries are fine. Whatever the decision, these need changes:
- Newly live check:
fixedOffsetOfClientPoint(ContextMenu.tsx:279-294) interleavesleft/topwrites withgetBoundingClientRectreads, so every open lays the page out at least twice againstarchitecture:react-component-runtimeINV18; read the 1 px anchor once at its current offset and write once. - Newly live check:
useContextMenu.tsx:153writes the latest-value reflatestRefinside a layout effect, while INV3 routes such a ref only throughuseCommittedRef. - Miss:
createContextMenu.tsx:317keeps{element, handleRef}in React state, which INV1 forbids for DOM nodes; build the attachment once in the factory and pass it down. - The dense docs at
createContextMenu.doc.mjs:138sayrenderfills the menu when it opens, but it runs once at attach and its cleanup runs atdestroy. - Miss: no test fails when a listener (the element's
keydown, the long-press recognizer, or the open menu's documentmousedown) survivesdestroy, whichspec:AST-107FR8's verification asks for. - Miss:
ContextMenu.tsxis shared with Table and grows by the attached-menu code every ContextMenu and Table page loads, soarchitecture:component-import-boundariesINV10 asks for base-against-head first-load gzip deltas on the docs, form, menu and table reference pages.
Claims and files checked
Review mode: incremental; reason: none
Changed rules (1): "When the issued head equals the head of CodeBunny's latest complete review" - checked: the issued head and the latest reviewed head differ, so the same-head rule does not govern this review; no finding
Claims:
- Changeset: attaches ContextMenu's menu to any element without wrapping it - verified (the factory's host is never a child of the element)
- Changeset: a ListItem row keeps
ul > liand its dividers - verified by code (the host is appended outside the list; ListItem's divider rule); tests not run here - Changeset: opens on a long press, a right click, Shift+F10 or the context-menu key - verified by code (the shared context-request module)
- Changeset:
destroyremoves every listener and node it added - verified by enumerating the element listeners, the recognizer, the host and the root's effects; no test counts listeners (finding above) - Title: a headless context menu per AST-107 FR8 - partly: FR8's clause that ContextMenu is built on the factory does not hold yet (owner decision)
- Description: a ContextMenu around a ListItem gives
ul > div > liand drops the dividers - verified (the control test and ListItem's divider rule) - Description: both APIs come from the ContextMenu entry, the hook also from the hooks entry - verified (both entry files)
- Description: the menu lives at the end of the element's dialog, popover, shadow root or body, and the element's markup is untouched - verified by code
- Description: ContextMenu's API and output do not change - verified by reading the changed files and the modules that import ContextMenu
- Description: only ContextMenu.tsx and createContextMenu.tsx use the shared root - verified by a repository search (2 files)
- Description: the lift under a finger and the More actions button stay open - verified (recorded as gaps, approved)
- Description: the last commit adds the two hook routes to the route lock and changes no other file - verified (that commit changes one file, 10 added lines)
- Description: the merge with
mainis clean, and of this pull request's files only the route lock changed there - verified at the currentmain - Description: the docsite build stops at the route lock check before the last commit and passes at this head - reported (CI's docsite build runs the same check; it has not run at this head)
- Description: test runs and counts, preflight results, red-first runs, the WebKit run, one-off controls and rubric results - reported (CI has not run at this head)
- Description: public text carries no internal context - verified (residue scan over the added lines, commits, title, body and branch: no match)
Files:
- .changeset/createcontextmenu-element-options-attaches-conte-k1sw.md - clear
- apps/storybook/stories/ContextMenu.stories.tsx - clear
- docs/specs/components/ContextMenu/ContextMenu.spec.md - clear (approved at this head)
- docs/specs/components/List/List.spec.md - clear (approved at this head)
- internal/shadcn-registry/routes.lock.json - clear
- packages/cli/foundation/doc-compiler/inputs.test.mjs - clear
- packages/core/src/ContextMenu/ContextMenu.doc.mjs - clear
- packages/core/src/ContextMenu/ContextMenu.tsx - forced layout on open; first-load numbers missing; bypass of the factory held for an owner
- packages/core/src/ContextMenu/tests/createContextMenu.interaction.browser.spec.ts - clear
- packages/core/src/ContextMenu/contextMenuRequests.ts - clear
- packages/core/src/ContextMenu/contextMenuRows.tsx - clear
- packages/core/src/ContextMenu/createContextMenu.doc.mjs - dense
renderdescription - packages/core/src/ContextMenu/createContextMenu.ssr.test.tsx - clear
- packages/core/src/ContextMenu/createContextMenu.test.tsx - no listener check after
destroy - packages/core/src/ContextMenu/createContextMenu.tsx - DOM node in state; long header (non-blocking)
- packages/core/src/ContextMenu/index.ts - clear
- packages/core/src/ContextMenu/useContextMenu.doc.mjs - clear
- packages/core/src/ContextMenu/useContextMenu.test.tsx - clear
- packages/core/src/ContextMenu/useContextMenu.tsx - latest-value ref in a layout effect; long header (non-blocking)
- packages/core/src/List/tests/ListItemContextMenu.test.tsx - clear
- packages/core/src/hooks/index.ts - clear
- scripts/touch-support-bundle.test.mjs - clear
There was a problem hiding this comment.
Changes requested. An engineering owner's approval at this head settles the spec side, including ContextMenu keeping its own invocation and both APIs shipping without a live template example for now. These code and evidence items remain before approval:
- Newly live check:
fixedOffsetOfClientPoint(ContextMenu.tsx:279-294) interleavesleft/topwrites withgetBoundingClientRectreads, so every open lays the page out at least twice againstarchitecture:react-component-runtimeINV18; read the 1 px anchor once at its current offset and write once. - Newly live check:
useContextMenu.tsx:153writes the latest-value reflatestRefinside a layout effect, while INV3 routes such a ref only throughuseCommittedRef. - Miss:
createContextMenu.tsx:317keeps{element, handleRef}in React state, which INV1 forbids for DOM nodes; build the attachment once in the factory and pass it down. - The dense docs at
createContextMenu.doc.mjs:138sayrenderfills the menu when it opens, but it runs once at attach and its cleanup runs atdestroy. - Miss: no test fails when a listener (the element's
keydown, the long-press recognizer, or the open menu's documentmousedown) survivesdestroy, whichspec:AST-107FR8's verification asks for. - Miss:
ContextMenu.tsxis shared with Table and grows by the attached-menu code every ContextMenu and Table page loads, soarchitecture:component-import-boundariesINV10 asks for base-against-head first-load gzip deltas on the docs, form, menu and table reference pages.
Claims and files checked
Review mode: same-head; reason: none
Title: feat(ContextMenu): createContextMenu and useContextMenu, a headless context menu (spec:AST-107 FR8)
Changed rules (0): none since the earlier review at this head
Claims:
- Changeset: attaches ContextMenu's menu to any element without wrapping it - verified (the factory's host is never a child of the element)
- Changeset: a ListItem row keeps
ul > liand its dividers - verified by code (the host is appended outside the list; ListItem's divider rule); tests not run here - Changeset: opens on a long press, a right click, Shift+F10 or the context-menu key - verified by code (the shared context-request module)
- Changeset:
destroyremoves every listener and node it added - verified by enumerating the element listeners, the recognizer, the host and the root's effects; no test counts listeners (finding above) - Title: a headless context menu per AST-107 FR8 - verified for the factory and hook; ContextMenu's move onto the factory is an owner-accepted gap
- Description: a ContextMenu around a ListItem gives
ul > div > liand drops the dividers - verified (the control test and ListItem's divider rule) - Description: both APIs come from the ContextMenu entry, the hook also from the hooks entry - verified (both entry files)
- Description: the menu lives at the end of the element's dialog, popover, shadow root or body, and the element's markup is untouched - verified by code
- Description: ContextMenu's API and output do not change - verified by reading the changed files and the modules that import ContextMenu
- Description: only ContextMenu.tsx and createContextMenu.tsx use the shared root - verified by a search of Core's source
- Description: the lift under a finger and the More actions button stay open - verified (recorded as gaps, approved)
- Description: the last commit adds the two hook routes to the route lock and changes no other file - verified (that commit changes one file, 10 added lines)
- Description: the merge with
mainis clean, and of this pull request's files only the route lock changed there - verified at the currentmain - Description: the docsite build stops at the route lock check before the last commit and passes at this head - reported (CI's docsite build runs the same check; it has not run at this head)
- Description: test runs and counts, preflight results, red-first runs, the WebKit run, one-off controls and rubric results - reported (CI has not run at this head)
- Description: public text carries no internal context - verified (scan over the added lines, commits, title, body and branch: no match)
Files:
- .changeset/createcontextmenu-element-options-attaches-conte-k1sw.md - clear
- apps/storybook/stories/ContextMenu.stories.tsx - clear
- docs/specs/components/ContextMenu/ContextMenu.spec.md - clear (approved at this head)
- docs/specs/components/List/List.spec.md - clear (approved at this head)
- internal/shadcn-registry/routes.lock.json - clear
- packages/cli/foundation/doc-compiler/inputs.test.mjs - clear
- packages/core/src/ContextMenu/ContextMenu.doc.mjs - clear
- packages/core/src/ContextMenu/ContextMenu.tsx - forced layout on open; first-load numbers missing
- packages/core/src/ContextMenu/tests/createContextMenu.interaction.browser.spec.ts - clear
- packages/core/src/ContextMenu/contextMenuRequests.ts - clear
- packages/core/src/ContextMenu/contextMenuRows.tsx - clear
- packages/core/src/ContextMenu/createContextMenu.doc.mjs - dense
renderdescription - packages/core/src/ContextMenu/createContextMenu.ssr.test.tsx - clear
- packages/core/src/ContextMenu/createContextMenu.test.tsx - no listener check after
destroy - packages/core/src/ContextMenu/createContextMenu.tsx - DOM node in state; long header (non-blocking)
- packages/core/src/ContextMenu/index.ts - clear
- packages/core/src/ContextMenu/useContextMenu.doc.mjs - clear
- packages/core/src/ContextMenu/useContextMenu.test.tsx - clear
- packages/core/src/ContextMenu/useContextMenu.tsx - latest-value ref in a layout effect; long header (non-blocking)
- packages/core/src/List/tests/ListItemContextMenu.test.tsx - clear
- packages/core/src/hooks/index.ts - clear
- scripts/touch-support-bundle.test.mjs - clear
An attached open measured its anchor at two offsets, so each open laid out twice, with writes between its reads. One case counts the layouts that two opens force through a scaled containing block, and checks where the anchor goes. Two cases count the listeners a menu adds to the element, the document and the window, and expect none after destroy: its keys, its long press and its document press while open.
An attached open measured its anchor at two offsets, with writes between its reads. It now reads the element's box and the anchor's drawn box where the anchor is, and then writes the anchor's offsets once. The anchor's drawn size against its layout size gives the containing block's scale, and its current offsets give the origin. useContextMenu's latest options go through useCommittedRef. The factory builds the element's attachment once, instead of keeping it in React state. The dense docs say that `render` fills the menu once, as it attaches, and that its cleanup runs on destroy.
createContextMenu's docs said that `render` fills the menu once, as it attaches. It runs when the menu's layer mounts, at the first open, so a closed menu that never opened builds nothing. The docs and the comment now say so. A new case attaches menus to five rows. It checks that none built a menu or ran `render` before an open, that the first open runs it once, that a reopen does not run it again, and that destroy runs its cleanup once.
|
/approve-spec 5d57d6d |
There was a problem hiding this comment.
Changes requested. The spec side is settled: an engineering owner approved this head. Two fixes remain:
- Miss: an open re-appends the menu's host whenever it is not its parent's last child (
createContextMenu.tsx:397-401), so in a list with a menu on every row the open's reads follow that DOM move and the layer reads again after the anchor write, laying the page out twice against react-component-runtime INV18; move the host only when its parent changes, and add a case with two menus. render's docs and comments (createContextMenu.doc.mjs:38,:138,createContextMenu.tsx:64-66,:349-351) promise one fill at the first open and one cleanup atdestroy, but withpresentation: 'bottom-sheet'(or'adaptive'on a touch screen) the sheet remounts its content, sorenderruns at every open and its cleanup at every close; document that or keep the sheet's content mounted, and add a sheet case.
Both findings sit on the inline threads at these lines. CI has not run the tests at this head, since this pull request is a draft.
Claims and files checked
Review mode: same-head; reason: none
- changed rules (0): none
- Live title, "feat(ContextMenu): createContextMenu and useContextMenu, a headless context menu (spec:AST-107 FR8)": verified (both APIs ship from the ContextMenu folder with the signatures the gesture-hooks spec gives)
- Release note: the factory attaches the menu to any element without a wrapper: verified (
createContextMenu.tsx:248-255,:397-404) - Release note: a ListItem row keeps
ul > liand its dividers: verified by the unit and browser cases' assertions (ListItemContextMenu.test.tsx, the interaction spec); not run here - Release note: a long press, a right click, Shift+F10 or the context-menu key opens it: verified (
gestures/contextRequest.ts:175,:199) - Release note:
destroyremoves every listener and node it added: verified; the element's listeners and long press go with the request (contextMenuRequests.ts:88-95), the open menu's document listeners and the host with the teardown (createContextMenu.tsx:476-496); the page's shared gesture host is shared infrastructure - Description: a ContextMenu wrapper gives
ul > div > li: verified (control case) - Description: every divider disappears inside a wrapper: reported
- Description: signatures and entry points: verified (
ContextMenu/index.ts,hooks/index.ts, the package's exports map) - Description: rows, keys, presentations and dismissal are ContextMenu's: verified (shared root)
- Description: the menu lives at the end of the element's dialog, popover, shadow root or body: verified (
createContextMenu.tsx:248-255) - Description: ContextMenu's API and output do not change: verified by reading
- Description: only
ContextMenu.tsxandcreateContextMenu.tsxuse the shared root: verified (a search of the head's packages and apps for the attached menu: those two files) - Description:
renderfills the menu once, at its first open, and cleans up on destroy: false under the bottom sheet - Description: each attached open forces at most one layout: false when the open moves the host
- Description: the new listener cases expect none after
destroy: verified (case content); their mutation results reported - Description: the merge keeps both sides' routes, and only the route lock overlaps: verified
- Description: first-load gzip deltas docs +0 B, form +0 B, menu +333 B, table +351 B: reported
- Description: unit, interaction, WebKit, preflight, typecheck and lint runs: reported
.changeset/createcontextmenu-element-options-attaches-conte-k1sw.md: clearapps/storybook/stories/ContextMenu.stories.tsx: cleardocs/specs/components/ContextMenu/ContextMenu.spec.md: clear (approved)docs/specs/components/List/List.spec.md: clear (approved)internal/shadcn-registry/routes.lock.json: clear (generated)packages/cli/foundation/doc-compiler/inputs.test.mjs: clearpackages/core/src/ContextMenu/ContextMenu.doc.mjs: clearpackages/core/src/ContextMenu/ContextMenu.tsx: the open's read and write sequence (finding 1)packages/core/src/ContextMenu/__tests__/createContextMenu.interaction.browser.spec.ts: clearpackages/core/src/ContextMenu/contextMenuRequests.ts: clearpackages/core/src/ContextMenu/contextMenuRows.tsx: clearpackages/core/src/ContextMenu/createContextMenu.doc.mjs:rendertiming (finding 2)packages/core/src/ContextMenu/createContextMenu.ssr.test.tsx: clearpackages/core/src/ContextMenu/createContextMenu.test.tsx: the layout case covers one menu only (finding 1); no sheet case (finding 2)packages/core/src/ContextMenu/createContextMenu.tsx: host move (finding 1),rendercomments (finding 2)packages/core/src/ContextMenu/index.ts: clearpackages/core/src/ContextMenu/useContextMenu.doc.mjs: clearpackages/core/src/ContextMenu/useContextMenu.test.tsx: clearpackages/core/src/ContextMenu/useContextMenu.tsx: clearpackages/core/src/List/__tests__/ListItemContextMenu.test.tsx: clearpackages/core/src/hooks/index.ts: clearscripts/touch-support-bundle.test.mjs: clear
An open re-appended the menu's container whenever it was not its parent's last child, so in a list with a menu on every row an open moved a node before its layout reads. The container now moves only when the element is in another dialog, popover, shadow root or body, and the theme attributes it mirrors are written only when they change. A bottom sheet mounts its content as it opens and unmounts it after it closes, as ContextMenu's sheet does, so there `render` runs at each open and its cleanup after each close. The docs and comments say so. Two cases: two menus, where an open moves no node and writes no attribute; and a bottom sheet, which fills at each open and cleans up after each close.
useContextMenu rendered each element's menuContent as it attached, so a list with a menu on every row rendered every row's content on mount. It now keeps the content, and renders it when the factory fills the menu at its first open, as the factory's own render does. It stays rendered after, so a reopen does not render it again. A new case attaches menus to five rows. None renders its content before an open; the first open renders it once, and a reopen does not.
|
/approve-spec 58dfdab |
There was a problem hiding this comment.
Approved pending CI. Both findings from the last review are fixed: an open in a list no longer moves the menu's container or writes theme attributes, and render's docs now say a bottom sheet fills the menu at each open and cleans up after each close. CI has not run on this head yet because the pull request is a draft; it runs once the pull request is marked ready for review, and the merge guard waits for it.
- Optional: the header of
contextMenuRows.tsxstill says the rows "stay rendered" so the first row is there when focus starts; sinceuseContextMenunow rendersmenuContentat the first open, "render at the menu's first open and stay rendered after" would match the code (inline note).
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Title: the pull request adds createContextMenu and useContextMenu, the headless context menu the gesture-hooks spec defines: verified (both ship from the ContextMenu folder with the spec's signatures)
- Release note: the factory attaches ContextMenu's menu to any element without wrapping it: verified (the host goes in the element's dialog, popover, shadow root or body,
createContextMenu.tsx:256-263,:409-415; the dialog, popover and shadow-root cases assert the menu is outside the element) - Release note: the hook does the same from a component: verified (
useContextMenu.tsx:200-239;useContextMenu.test.tsx:195) - Release note: a ListItem row keeps
ul > liand its dividers: verified by test content (ListItemContextMenu.test.tsxasserts onlylichildren and the same row classes as rows without a menu; the browser case reads each row's border) - Release note: a long press, a right click, Shift+F10 or the context-menu key opens it: verified (
gestures/contextRequest.ts:174-200; cases atcreateContextMenu.test.tsx:191,:219,:227,:736) - Release note:
destroyremoves every listener and node it added: verified (enumerated: the host, its React root, the element's keydown and contextmenu listeners, the long-press recognizer, the open menu's document listeners;createContextMenu.tsx:488-508,contextMenuRequests.ts:88-95; cases at:557,:571,:779); the page's shared gesture host is shared infrastructure - Description: a ContextMenu wrapper gives
ul > div > li: verified (control case inListItemContextMenu.test.tsx) - Description: every divider disappears inside a wrapper: reported (a one-off browser control); the reason follows from ListItem's last-child divider rule
- Description: signatures, options, returns and entry points: verified (
createContextMenu.tsx:75-107,useContextMenu.tsx:52-75,ContextMenu/index.ts,hooks/index.ts, the package's exports map) - Description: rows, keys, presentations and dismissal are ContextMenu's: verified (shared
ContextMenuRoot) - Description: ContextMenu's API and output do not change: verified by reading the changed file and its direct importers (ContextMenu renders
ContextMenuRootwith no attachment; same trigger, anchor classes and surface) - Description: only
ContextMenu.tsxandcreateContextMenu.tsxuse the shared root: verified (search of packages, apps and internal at the head for the attached menu: those two files;contextMenuRequests.tsimports only a request type) - Description: an open moves the menu's container only when the element is in another dialog, popover, shadow root or body, and writes a theme attribute only when it changes: verified (
createContextMenu.tsx:231-248,:409-415; two-menu case atcreateContextMenu.test.tsx:442) - Description: a bottom sheet fills the menu at each open and cleans up after each close, and the docs say so: verified (
DropdownMenu/MenuBottomSheet.tsx:43-65;createContextMenu.doc.mjs:38,:138; case atcreateContextMenu.test.tsx:487) - Description:
useContextMenurendersmenuContentat the first open, once, and not again on a reopen: verified (useContextMenu.tsx:92-133; case atuseContextMenu.test.tsx:158) - Description: in a popover
renderfills the menu once, at its first open, and its cleanup runs on destroy; no menu is built before an open: verified (case atcreateContextMenu.test.tsx:390) - Description: an attached open reads layout once, then moves its anchor once: verified (
ContextMenu.tsx:795-821; case atcreateContextMenu.test.tsx:589) - Description: the two listener cases expect none after destroy: verified (case content at
:571,:779); their mutation results: reported - Description: the head contains the merge of the base branch, only the route lock overlapped, and both sides' routes are kept: verified (history; the route lock gains only the two new routes)
- Description: the pull request adds no skipped or todo test: verified (search of the diff)
- Description: first-load gzip deltas docs +0 B, form +0 B, menu +333 B, table +351 B, unchanged at this head: reported
- Description: unit, interaction, WebKit, preflight, red-first, typecheck, lint and knowledge-check runs and counts: reported
.changeset/createcontextmenu-element-options-attaches-conte-k1sw.md: clearapps/storybook/stories/ContextMenu.stories.tsx: cleardocs/specs/components/ContextMenu/ContextMenu.spec.md: clear (owner-approved at this head)docs/specs/components/List/List.spec.md: clear (owner-approved at this head)internal/shadcn-registry/routes.lock.json: clear (generated route lock)packages/cli/foundation/doc-compiler/inputs.test.mjs: clearpackages/core/src/ContextMenu/ContextMenu.doc.mjs: clearpackages/core/src/ContextMenu/ContextMenu.tsx: clearpackages/core/src/ContextMenu/__tests__/createContextMenu.interaction.browser.spec.ts: clearpackages/core/src/ContextMenu/contextMenuRequests.ts: clearpackages/core/src/ContextMenu/contextMenuRows.tsx: clear (non-blocking: header says the rows stay rendered, now true from the first open)packages/core/src/ContextMenu/createContextMenu.doc.mjs: clear (bottom-sheet timing documented)packages/core/src/ContextMenu/createContextMenu.ssr.test.tsx: clearpackages/core/src/ContextMenu/createContextMenu.test.tsx: clear (two-menu and bottom-sheet cases added)packages/core/src/ContextMenu/createContextMenu.tsx: clear (the host moves only when its container changes; non-blocking: long file header)packages/core/src/ContextMenu/index.ts: clearpackages/core/src/ContextMenu/useContextMenu.doc.mjs: clearpackages/core/src/ContextMenu/useContextMenu.test.tsx: clear (first-open render case added)packages/core/src/ContextMenu/useContextMenu.tsx: clear (menuContent renders at the first open; non-blocking: long file header)packages/core/src/List/__tests__/ListItemContextMenu.test.tsx: clearpackages/core/src/hooks/index.ts: clearscripts/touch-support-bundle.test.mjs: clear
| * hands createContextMenu a `render` for its rows. The rows stay rendered | ||
| * into a host the menu's container adopts, so the first enabled row is | ||
| * there when focus starts, and they read the menu's own row context, open | ||
| * state and layer |
There was a problem hiding this comment.
Non-blocking (comment accuracy): since useContextMenu renders menuContent at the menu's first open, the rows no longer "stay rendered" from attach. Suggested: "The rows render into a host the menu's container adopts, at the menu's first open, and stay rendered after; they read the menu's own row context, open state and layer."
There was a problem hiding this comment.
Changes requested, and one owner decision. Two claims in this pull request's text are false at this head; the last review could already see both and missed them. Approval also waits on an engineering owner ruling whether spec:AST-107 FR8's "destroy removes every listener it added" lets the page-wide listeners below stay, or amending FR8.
- Miss: The changeset says "
destroyremoves every listener and node it added", but attaching and destroying the first menu on a page leaves seven document and window listeners (React's ownselectionchangefrom the factory's root, the layer gesture counter's four and the input-modality tracker's two; reproduced locally), and both listener-count tests attach and destroy another menu before they count, so reword the changeset and thedestroydocs (createContextMenu.doc.mjs:81,:147,createContextMenu.tsx:105) to say whatdestroyremoves. - Miss: The description says "The element's markup is untouched", but attaching writes
data-astryx-touch-action="manipulation"on the element untildestroy(reproduced locally and in Chromium on the head's Storybook), which also turns off double-tap zoom there, so reword it, and the same sentence increateContextMenu.doc.mjs:25,:135,useContextMenu.doc.mjs:22andcreateContextMenu.tsx:23, to say the menu adds no wrapper or child.
CI passes at this head.
Claims and files checked
Review mode: same-head; reason: none
- changed rules (3): Claim bounding in one round; A claim bounded by a record is bounded; The rules above still apply
- Claim bounding in one round: two findings over the whole pull request, every case listed: the destroy claim (React's root listener, the layer gesture counter, the input-modality tracker) and the markup claim (the touch-action mark; on iOS WebKit, the selection lock's inline styles during a hold); both marked as missed
- A claim bounded by a record is bounded: checked the title's and the description's record citations (gesture-hooks spec FR8, List FR13, ContextMenu FR10) against the current records; no finding
- The rules above still apply: checked every case the changeset and description list (below); findings as above
- Live title "feat(ContextMenu): createContextMenu and useContextMenu, a headless context menu (spec:AST-107 FR8)": verified (both ship from the ContextMenu folder with the spec's signatures)
- Release note: the factory attaches ContextMenu's menu to an element without wrapping it: verified (
createContextMenu.tsx:255-263,:409-415; dialog, popover and shadow-root cases) - Release note: the hook does the same from a component: verified (
useContextMenu.tsx:200-239;useContextMenu.test.tsx:129) - Release note: a ListItem row keeps
ul > liand its dividers: verified (ListItemContextMenu.test.tsx; the browser case reads each row's border and passes in CI; capture here) - Release note: a long press, a right click, Shift+F10 or the context-menu key opens it: verified (
gestures/contextRequest.ts:92-106,:172-200; casescreateContextMenu.test.tsx:191,:219,:227,:736; capture here) - Release note:
destroyremoves every listener and node it added: false (seven page listeners stay after a first menu's destroy; no node stays) - Description: ContextMenu wraps its trigger, giving
ul > div > li: verified (control case inListItemContextMenu.test.tsx) - Description: every divider disappears inside a wrapper: reported (the author's browser control); the reason is ListItem's last-child rule (
List/ListItem.tsx:270-272) - Description: the gesture-hooks spec defines both APIs, List gives a row a menu through its ref, ContextMenu's gap sentence changes: verified against the current records
- Description: signatures, options, returns and entry points: verified (
createContextMenu.tsx:75-107,useContextMenu.tsx:52-75,ContextMenu/index.ts,hooks/index.ts; CI's API report lists the same rows) - Description: rows, keys, presentations and dismissal are ContextMenu's: verified (shared
ContextMenuRoot) - Description: the menu lives in the element's dialog, popover, shadow root or body: verified (
createContextMenu.tsx:255-263) - Description: the element's markup is untouched: false (
data-astryx-touch-actionwhile attached) - Description: ContextMenu's API and output do not change: verified by reading
ContextMenu.tsxand CI's visual report (11 of 12 shots unchanged; the changed one is the story's dashed demo border, also changed on another pull request) - Description: only
ContextMenu.tsxandcreateContextMenu.tsxuse the shared root: verified (search of packages, apps and internal at the head) - Description: an open moves the container only when the element's container changed and writes a theme attribute only when it changed: verified (
createContextMenu.tsx:231-248,:409-415; case:442) - Description: a bottom sheet fills the menu at each open and cleans up after each close, and the docs say so: verified (case
:487;createContextMenu.doc.mjs:38,:138) - Description:
useContextMenurendersmenuContentat the first open, once: verified (caseuseContextMenu.test.tsx:158) - Description: in a popover
renderfills the menu once at its first open, cleanup on destroy, no menu before an open: verified (casecreateContextMenu.test.tsx:390) - Description: an attached open reads layout once, then moves its anchor once: verified (
ContextMenu.tsx:795-821; case:589) - Description: the two listener cases expect none after
destroy: verified as test content, which counts only after a first menu (finding above); their mutation results: reported - Description: the head contains the base-branch merge, and the route lock keeps both sides' routes: verified (history; CI's docsite build passes)
- Description: the pull request adds no skipped or todo test: verified (search of the diff)
- Description: first-load gzip deltas docs +0 B, form +0 B, menu +333 B, table +351 B: reported
- Description: unit, interaction, WebKit, preflight, red-first, typecheck, lint and knowledge-check runs and counts: reported; CI at this head runs and passes the unit, interaction (with WebKit), accessibility, typecheck, lint and docsite jobs
.changeset/createcontextmenu-element-options-attaches-conte-k1sw.md: finding (destroy claim)apps/storybook/stories/ContextMenu.stories.tsx: cleardocs/specs/components/ContextMenu/ContextMenu.spec.md: clear (owner-approved at this head)docs/specs/components/List/List.spec.md: clear (owner-approved at this head)internal/shadcn-registry/routes.lock.json: clear (generated route lock)packages/cli/foundation/doc-compiler/inputs.test.mjs: clearpackages/core/src/ContextMenu/ContextMenu.doc.mjs: clearpackages/core/src/ContextMenu/ContextMenu.tsx: clearpackages/core/src/ContextMenu/__tests__/createContextMenu.interaction.browser.spec.ts: clearpackages/core/src/ContextMenu/contextMenuRequests.ts: clearpackages/core/src/ContextMenu/contextMenuRows.tsx: clear (non-blocking: header wording)packages/core/src/ContextMenu/createContextMenu.doc.mjs: finding (markup and destroy wording)packages/core/src/ContextMenu/createContextMenu.ssr.test.tsx: clearpackages/core/src/ContextMenu/createContextMenu.test.tsx: finding (listener cases skip the first-menu case)packages/core/src/ContextMenu/createContextMenu.tsx: finding (header anddestroyJSDoc wording; non-blocking: long header)packages/core/src/ContextMenu/index.ts: clearpackages/core/src/ContextMenu/useContextMenu.doc.mjs: finding (markup wording)packages/core/src/ContextMenu/useContextMenu.test.tsx: clearpackages/core/src/ContextMenu/useContextMenu.tsx: clear (non-blocking: long header)packages/core/src/List/__tests__/ListItemContextMenu.test.tsx: clearpackages/core/src/hooks/index.ts: clearscripts/touch-support-bundle.test.mjs: clear
| name: 'element', | ||
| type: 'HTMLElement', | ||
| description: | ||
| 'The element that owns the menu, already on the page, such as a list row. Its markup is untouched: the menu renders outside it, so a `li` row keeps its list valid.', |
There was a problem hiding this comment.
Miss (the last review saw this line): attaching writes data-astryx-touch-action="manipulation" on the element until destroy (the context request's long press asks the gesture host for it), so double-tap zoom is off on the element and its markup is not untouched. Reproduced locally and in Chromium on the head's Storybook, where every ListItem row with a menu carries it. Suggested: "The element that owns the menu, already on the page, such as a list row. The menu adds no wrapper or child: it renders outside the element, so a li row keeps its list valid. While attached, the element carries a touch-action mark." The same sentence is at :135, in useContextMenu.doc.mjs:22 and in the header of createContextMenu.tsx (:23).
| }); | ||
|
|
||
| it('destroy removes every listener it added, the keys and the document press while open included (spec:AST-107 FR8)', () => { | ||
| // A first menu adds what the document keeps for every menu after it. |
There was a problem hiding this comment.
This first attach and destroy hides exactly the case that makes the release note's destroy claim false: the listeners it leaves are the seven a page keeps after its first menu. Once the wording (or the owner's reading of the gesture-hooks spec's destroy clause) is settled, a case without this step that asserts which listeners stay would pin it. The same step is at :781.



User need
A product that already renders an element, such as a list row, cannot give it a context menu without wrapping it. ContextMenu wraps its trigger, so a ListItem inside it gives
ul > div > li, which HTML does not allow. Every divider then disappears (test).Problem and solution fit
libelongs directly in its list, and ContextMenu's trigger wrapper sits between them.createContextMenuattaches ContextMenu's own menu to an element without wrapping it, anduseContextMenudoes it from a component.Current specification
spec:AST-107FR8 defines both APIs.component:ListFR13 gives a row a menu through its ref, keepingul > li.component:ContextMenuFR10's gap sentence changes here, with its impact line and List's readiness row.Public delta and caller burden
createContextMenu(element, {items | render, label?, isDisabled?, onOpenChange?, presentation?})returns{open(at?), close(), destroy()}.useContextMenu(ref, options)returns{open, close}, and takesmenuContentJSX as ContextMenu does.@astryxdesign/core/ContextMenu; the hook also from@astryxdesign/core/hooks.Design and alternatives
ContextMenu's body becomes one internal root with two entries: ContextMenu, with its wrapper, and the attached menu the factory renders. Only
ContextMenu.tsxandcreateContextMenu.tsxuse that root.Still open: the lift under a finger (
spec:AST-094FR33) and a plain row's More actions button (component:ListOQ2).Evidence
main, where neither API exists (test).ul > liand every divider but the last row's (test).Scope
Components: ContextMenu, List
Testing
renderruns at each open and its cleanup after each close, and the docs say so. A case pins that, and fails when the sheet stays mounted (test).useContextMenurendersmenuContentat the menu's first open, not as it attaches. In a case with five rows, none renders its content before an open (test). The first open renders it once, and a reopen does not; the hook as it was rendered all five at attach (test).createContextMenu's interaction spec passes in Chromium, and the core typecheck and strict ESLint pass (test). The page sizes below are unchanged at this head (test).render's docs: in a popover it fills the menu once, at its first open, and its cleanup runs on destroy. Its case attaches menus to five rows, and none builds a menu or runsrenderbefore an open (test). With the menu's layer mounted at attach, that case fails (test).pnpm preflight --browserat a80073e (CI unset,VITEST_MAX_WORKERS=12,ASTRYX_STRICT_LINT=1) reports "ready to flip" (test). Its unit steps passed 27,880 tests, and 30,407 with 3 expected fails (test). The node step skips 14 files and 108 tests and has 1 todo; this PR adds no skip or todo (test). Its accessibility step passed 187 and skipped 4, and its interaction step passed 2,038 and skipped 54 (test).main2999b15 into a80073e as a new commit. Of this PR's files, only the route lock changed onmain, and the merge keeps both sides' routes.createContextMenu's interaction spec in Chromium, the core typecheck and strict ESLint pass (test).pnpm size:pages --base 2999b1585 --head 06a9bca99measures the first-load JavaScript gzip delta on the four reference pages of the import-boundaries record's INV10 (test). Gzip: docs +0 B, form +0 B, menu +333 B and table +351 B (test). The menu and table pages load ContextMenu, which this PR changes.destroy(test). They pass on the code as it was (test). Each fails when one removal is taken out: the keydown's, the long press's or the document press's (test).pnpm exec vitest run --project ui packages/core/src/ContextMenu/at a80073e: 125 tests pass (test).createContextMenu's interaction spec passes in Chromium there (test).latestRefin auseCallback's dependencies (test).pnpm preflight --browserat 64721fa also reported "ready to flip" (test). The commit after it adds the two new hooks' routes,hooks/create-context-menuandhooks/use-context-menu, tointernal/shadcn-registry/routes.lock.json. At 64721fa,pnpm -F @astryxdesign/docsite buildstops at the route-lock check; from that commit on it passes (test).pnpm test:interaction packages/core/src/ContextMenu/__tests__/createContextMenu.interaction.browser.spec.ts --project=chromium: 10 tests pass (test).webkit-container.mjsand the Playwright image it names.divdrew no divider (test). Chromium's accessibility tree ignored the wrappers and still showed four list items (test).main9380b40 fail to load: neither API exists there (test).pnpm check:knowledge: templates and records are aligned.Writing rubric results
component:ListOQ2 stays open.mainstill say "yet".Drafted with an AI coding agent; the tests were run as described.